<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    {{msg}}
    <hello @pfn="getData"></hello>
</div>
<script src="vue.js"></script>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            msg: 'hello component'
        },
        methods: {
            getData: function (data) {
                this.msg = '子组件传递过来的数据：' + data
            }
        },
        components: {
            hello: {
                template: `<h1>
               子组件中的内容：
               <button @click="fn">传递数据给父</button>
             </h1>`,
                methods: {
                    fn() {
                        this.$emit('pfn', '子组件宏的数据')
                    }
                }
            }
        }
    })
</script>
</body>
</html>